<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE html>
<html lang="en">
<head>
<title><s:message code="app.title" /></title>
<%@ include file="Include.jsp"%>
<script type="text/javascript">
$(document).ready(function() {
	$("#departmentname").focus();
	
	$('#cancelDepartment').click(function(){
		$('#cancelForm').attr('action','EditBranch');
		$('#cancelForm #branchid').val($('#departmentForm #branchId').val());
		$('#cancelForm #companyId').val($('#departmentForm #companyId').val());
		$('#cancelForm').attr('method','get');
		$('#cancelForm').submit();
	});
	
	$('#addDepartment').click(function(){
		$('#departmentForm').attr('action','AddDepartment');
		$('#departmentForm').attr('method','post');
		$('#departmentForm').submit();
	});
});
	
</script>
</head>
<body>
	<div class="container">
		<%@ include file="Menu.jsp"%>
		<h2><s:message code="departmentForm.addheader" /></h2>
		<hr>
		<form:form id="cancelForm">		
			<input type="hidden" name="branchid" id="branchid"> 
			<input type="hidden" name="companyId" id="companyId"> 	
		</form:form>
		<form:form class="form-horizontal" method="post" name="departmentForm" id="departmentForm" commandName="DepartmentForm"
	           modelAttribute="departmentForm" >
			
			<table class="table table-bordered">
			<tr>
				<th width="15%"><form:label path="departmentname"><s:message code="departmentForm.departmentname" />
				<font color="red">*</font>
				</form:label></th>
				
				<th width="15%"><form:label path="departmentname"><s:message code="departmentForm.departmentname" /></form:label></th>
				<td width="*">
				<form:hidden path="branchId" id="branchId" value="${branchId}"/>
				<form:hidden path="companyId" id="companyId" value="${companyId}"/>
				
				<form:input path="departmentname" cssClass="input-medium" id="departmentname" maxlength="40" size="40" tabindex="1" />
				<form:errors cssClass="text-error" path="departmentname" />
				</td>
				
				<th width="15%"><form:label path="departmentinfo"><s:message code="departmentForm.departmentinfo" />
				<font color="red">*</font>
				</form:label></th>
				<td width="*">
					<form:input path="departmentinfo" maxlength="50" size="50" id="departmentinfo" cssClass="input-xlarge" />
					<form:errors cssClass="text-error" path="departmentinfo" />
				</td>
				
			</tr>
		</table>
			<button class="btn btn-primary" type="button" id="addDepartment" ><s:message code="app.add" /></button>
			<button class="btn btn-primary" type="button" id="cancelDepartment"  >
			<s:message code="app.cancel" /></button>
		</form:form>	
		<br/>
		 <%@ include file="Footer.jsp"%>
	</div>
</body>
</html>